import request from '@/utils/request'

/**
 * 获取文章列表
 * @param {*} params
 * @returns
 */
export const getArticles = params => {
  return request({
    url: '/v1_0/mp/articles',
    method: 'get',
    params,
  })
}

export const delArticle = id => {

  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: 'DELETE',
  })
}

// 发布文章
export const addArticle = (data, draft) => {

  return request({
    url: `/v1_0/mp/articles`,
    method: 'POST',
    params: {
      draft
    },
    data
  })
}

// 根据id获取文章详情
export const getArticleById = (id) => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: 'get',
  })
}

// 修改文章
export const editArticleById = (id,data, draft) => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: 'PUT',
    params: {
      draft,
    },
    data,
  })
}